Accusoft.OCRXpress.Java - Updated
Create a Full Page OCR Application
User Guide > How To ... > Create a Full Page OCR Application

OCR Xpress for Java makes it very easy to create a full page OCR application. For the basics, there are two ways to produce searchable text documents from images:

In addition, text in memory can be generated for the OCR Xpress internal data.

  1. Load an image into the java type BufferedImage:
    All three processes (i.e., generating PDF, TXT or document object in memory) require that the image be loaded first.
    Copy Code
      //Read in the image from inputImagePath
      BufferedImage bufferedImg = null;
      try {
        bufferedImg = ImageIO.read(new File(inputImagePath));
      }
      catch (IOException e) {
        e.printStackTrace();
        return;
      }
    
  2. Create the OcrXpress and RecognitionParameters object:
    Copy Code
    RecognitionParameters parameters = new RecognitionParameters();
    parameters.setLanguage(Language.ENGLISH);
    OcrXpress ocrx = new OcrXpress();
    
  3. After an Image has been loaded it may be processed by the OcrXpress object using the specified parameters in one of three ways.
    • Generate a PDF file:
      Copy Code
      ocrx.recognizeToFile(parameters, bufferedImg, FileFormat.PDF, FileMode.OVERWRITE, “PdfFileName.pdf”);
      
    • Generate a TXT file:
      Copy Code
      ocrx.recognizeToFile(parameters, bufferedImg, FileFormat.TEXT, FileMode.OVERWRITE, “TextFileName.txt”);
      
    • Generate a document object in memory:
      Copy Code
      Document document = ocrx.recognizeToMemory(parameters, bufferedImg);